<?php
/**
 * Created by PhpStorm.
 * User: GZJ
 * Date: 2017/4/10
 * Time: 17:02
 */
namespace Admin\Controller;
use Think\Controller;

class LoginController extends Controller{
    public function chkcode(){
        $config = array(
            'fontSize' => 30,
             'length' => 4,
             'useNoise' => false,
             );
        $Verify = new \Think\Verify($config);
        $Verify->entry();
    }
    public function login(){
        if(IS_POST){
            $model = D('admin');
            if($model->validate($model->_login_validate)->create()){
                if($model->login()){
                    $this->success('登录成功！',U('Index/index'));
                    exit;
                }
            }
            $this->error($model->getError());
        }
        $username = session('username');
       $this->assign('username',$username);
        $this->display();
    }

    public function logout(){
        $Model = D('Admin');
        $Model->logout();
        redirect('login');
    }
}